﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using XYS.Core.Models;
using XYS.Core.Util.Helper;

namespace XYS.Service.Core.Util.Helper
{
    /// <summary>
    /// 密码 帮助类
    /// </summary>
    public static partial class PasswordHelper
    {
        /// <summary>
        /// Hash 加密
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string EncryptPwd(string userName, string password)
        {
            if (string.IsNullOrWhiteSpace(userName)) throw new ArgumentNullException(nameof(userName));
            if (string.IsNullOrWhiteSpace(password)) throw new ArgumentNullException(nameof(password));

            // 将密码字符串和 key 字符串拼接起来，作为盐值
            return EncryptHelper.SHA512Encrypt($"{userName}-{password}");
        }

    }
}
